﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using NetDon.Utilities;

namespace NetDon.OA.Interface.Configuration
{
    public static class SystemConfiguration
    {
        public static readonly string RootCategoryName = "...(Root)";

        public static readonly string RootCompanyName = "祥狮物流有限公司集团";
        public static readonly string RootPositionName = "祥狮物流有限公司岗位";
        public static readonly string RootWorkflowName = "工作流分类";

        private const string DataFormatConfigurationName = "Date Format";


        private const string ThumbnailWidthConfigurationName = "Thumbnail Width";

        private const string ThumbnailHeightConfigurationName = "Thumbnail Height";


        public const string DefaultPassowrdConfigurationName = "Default Password";
        public const string BirthdayRemindDay = "Birthday Remind Days";
        public const string EOrderCancelLimitedDay = "EOrderCancelLimitedDay";
        public const string ManagerLevel = "ManagerLevel";

        private static readonly Guid oApplicationId = new Guid("a4638132-485d-de11-bb8e-002215ec82c2");

        public static string AdminEmail = "ceshi3@viewgres.com";
        public static string ApplicationName = "NetDon OA";
        public static string DateFormat = "yyyy-MM-dd";
        public static string TimeFormat = "HH:mm:ss";
        public static string DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        public static string DateMonthFormat = "yyyy-MM-dd HH:mm:ss";



        public const string TransportationPrefix = "Transportation Prefix";

        /// <summary>
        /// Gets the date time format info.
        /// </summary>
        /// <value>The date time format info.</value>
        public static DateTimeFormatInfo DateTimeFormatInfo
        {
            get
            {
                var formatInfo = new DateTimeFormatInfo
                {
                    ShortDatePattern = DateFormat,
                    FullDateTimePattern = DateTimeFormat
                };
                return formatInfo;

            }
        }

        public static Guid OApplicationId
        {
            get
            {
                return oApplicationId;
            }
        }


        /// <summary>
        /// Gets the default password.
        /// </summary>
        /// <value>The default password.</value>
        public static string DefaultTransportationPrefix(Guid areaId)
        {

            var service = ServiceContainer.GetService<IConfigurationService>();
            return service.GetConfiguration(new ConfigurationData()
                                                {
                                                    AreaId = areaId,
                                                    Name = TransportationPrefix
                                                });

        }



        /// <summary>
        /// Gets the width of the thumbnail.
        /// </summary>
        /// <value>The width of the thumbnail.</value>
        public static int ThumbnailWidth(Guid areaId)
        {

            var service = ServiceContainer.GetService<IConfigurationService>();
            var thumbnailWidth = service.GetConfiguration(new ConfigurationData()
                                                               {
                                                                   AreaId = areaId,
                                                                   Name = ThumbnailWidthConfigurationName
                                                               });
            return string.IsNullOrEmpty(thumbnailWidth) ? 120 : Convert.ToInt32(thumbnailWidth);

        }

        /// <summary>
        /// Gets the height of the thumbnail.
        /// </summary>
        /// <value>The height of the thumbnail.</value>
        public static int ThumbnailHeight(Guid areaId)
        {

            var service = ServiceContainer.GetService<IConfigurationService>();
            var thumbnailHeight = service.GetConfiguration(new ConfigurationData()
                                                               {
                                                                   AreaId = areaId,
                                                                   Name = ThumbnailHeightConfigurationName
                                                               });

            return string.IsNullOrEmpty(thumbnailHeight) ? 120 : Convert.ToInt32(thumbnailHeight);

        }

    }
}

